const http = require("http");
const fs = require("fs");
const path = require("path");
const url = require("url");

http.createServer((req, res) => {
    let urlObj = url.parse(req.url);

    switch (urlObj.pathname) {
        case "/":
            pageName = "02login.html";
            break;
        case "/header":
            let str = "User-Agent:" + req.headers["user-agent"] + "Host:" + req.headers["host"] + "Content-Type:" + req.headers["content-type"]
            res.end(JSON.stringify(req.headers) + str);
            return;
    }
    let filePath = path.join(__dirname, "testHeader.html");
    let fileContent = fs.readFileSync(filePath);
    res.end(fileContent);
}).listen(8080);
